/**
 * <p>Title: ShowFullPostAction.java</p>
 * <p>Description: DoNotes</p>
 * @author WangJun
 * @date 2009/11/29 1:18:03
 * @version 1.0
 */
package net.donotes.blog.action;

import java.util.List;

import net.donotes.blog.dao.CommentDao;
import net.donotes.blog.pojo.Comment;
import net.donotes.blog.pojo.Post;
import net.donotes.blog.service.PostService;

import com.google.appengine.api.datastore.Text;

/**
 * @author WangJun
 *
 */
public class ShowFullPostAction extends BaseAction {

	private static final long serialVersionUID = 1L;

    private Post post = new Post();
    private Post prePost = new Post();
    private Post nextPost = new Post();
	private Long postId = null;
	private List<Comment> comments = null;

	public String execute() {
		PostService postServiec = new PostService();
		this.post = postServiec.getPost(this.postId);
		if (this.post != null) {
			this.prePost = postServiec.getPrePost(this.post);
			this.nextPost = postServiec.getNextPost(this.post);
			this.post.setContent(new Text(this.post.getContent().getValue().replace("[more..]", "")));
			
			CommentDao commentDao = new CommentDao();
			this.comments = commentDao.listComment(this.post.getId());
		}
		return SUCCESS;
	}

	/**
	 * @return the postId
	 */
	public Long getPostId() {
		return postId;
	}

	/**
	 * @param postId the postId to set
	 */
	public void setPostId(Long postId) {
		this.postId = postId;
	}
	
	/**
	 * @return the post
	 */
	public Post getPost() {
		return post;
	}

	/**
	 * @return the prePost
	 */
	public Post getPrePost() {
		
		return prePost;
	}

	/**
	 * @return the nextPost
	 */
	public Post getNextPost() {
		return nextPost;
	}

	/**
	 * @return the comments
	 */
	public List<Comment> getComments() {
		return comments;
	}
}